﻿@{
    var categories = Sealight.UI.WebUI.Services.ProductService.GetAllProductCategory();
}
<select name="category_field" id="category_field" class="adminInput">
    <option value="">[ --- ]</option>
    @if (categories != null)
    {
        foreach (var cat in categories)
        {
            if (cat.id.ToString() == Model)
            {
        <option value="@cat.id" selected>@cat.name</option> 
            }
            else
            {
        <option value="@cat.id">@cat.name</option> 
            }
            if (cat.childrens != null)
            {
                foreach (var child in cat.childrens)
                {
                    if (child.id.ToString() == Model)
                    {
        <option value="@child.id" selected>--@child.name</option>  
                    }
                    else
                    {
        <option value="@child.id">--@child.name</option>  
                    }
                }
            }
        }
    }
</select>
